package test;

import java.util.Scanner;

public class MeiTuan2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        int bitCount = 0;
        int smallCount = 0;
        for (int i = 0; i < str.length() ; i++) {
            char c = str.charAt(i);
            if (c >= 'A' && c <= 'Z') {
                bitCount ++;
            } else if (c >= 'a' && c <= 'z') {
                smallCount ++;
            }
        }
        int res = Math.abs(bitCount - smallCount);
        System.out.println(res / 2);
    }
}
